package com.szgr.baoyin.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.StringRequest;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.szgr.baoyin.MyApplication;
import com.szgr.baoyin.R;
import com.szgr.baoyin.activity.AccessoryStoreActivity;
import com.szgr.baoyin.activity.BuyProtectActivity;
import com.szgr.baoyin.activity.FinanceActivity;
import com.szgr.baoyin.activity.LoginActivity;
import com.szgr.baoyin.activity.MyForumActivity;
import com.szgr.baoyin.activity.NewFinanceActivity;
import com.szgr.baoyin.activity.PrivilegeActivity;
import com.szgr.baoyin.activity.ProtectActivity;
import com.szgr.baoyin.activity.ProtectRuleActivity;
import com.szgr.baoyin.activity.QuestionActivity;
import com.szgr.baoyin.activity.SearchActivity;
import com.szgr.baoyin.activity.StoreActivity;
import com.szgr.baoyin.activity.StoreDeatilActivity;
import com.szgr.baoyin.activity.ToolStoreActivity;
import com.szgr.baoyin.activity.VipArticleActivity;
import com.szgr.baoyin.activity.VipRuleActivity;
import com.szgr.baoyin.adapter.AccessoriesGridAdapter;
import com.szgr.baoyin.adapter.CommonImagePagerAdapter;
import com.szgr.baoyin.adapter.MachineGridAdapter;
import com.szgr.baoyin.adapter.SpecialGridAdapter;
import com.szgr.baoyin.adapter.SpecialListAdapter;
import com.szgr.baoyin.adapter.SwitchPictureAdapter;
import com.szgr.baoyin.model.HomePageImage;
import com.szgr.baoyin.model.HomeTool;
import com.szgr.baoyin.model.ReduceGoods;
import com.szgr.baoyin.myview.NoScrollGridVIew;
import com.szgr.baoyin.myview.NoScrollListView;
import com.szgr.baoyin.utils.Constant;
import com.szgr.baoyin.utils.DialogUtils;
import com.szgr.baoyin.utils.JsonParser;
import com.szgr.baoyin.utils.MyTool;
import com.szgr.baoyin.utils.ToastUtils;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.w3c.dom.Text;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * 首页
 */
public class HomePageFragment1029 extends Fragment implements View.OnClickListener, AdapterView.OnItemClickListener {

    private static final int MSG_SWITCH_PIC = 333;
    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {

            switch (msg.what) {
                case Constant.REQUEST_SUCCESS:
                    pagerAdapter = new SwitchPictureAdapter(getActivity(), viewPager, data, view_parent,HomePageFragment1029.this);
                    viewPager.setAdapter(pagerAdapter);
                    pagerAdapter.setData(data);
                    if (data.size() > 1) {
                        viewPager.setCurrentItem(1);
                    }
                    DialogUtils.hideLoadingDialog();
                    break;
                case Constant.REQUEST_FAIL:
                    //TODO 首页轮播图失败，重新加载
                    DialogUtils.hideLoadingDialog();
                    break;
                case MSG_SWITCH_PIC:
                    if (viewPager != null) {
                        viewPager.setCurrentItem(viewPager.getCurrentItem() + 1);
                        this.sendEmptyMessageDelayed(MSG_SWITCH_PIC, 5 * 1000);
                    }
                    break;
                case 999:
//                    for (HomeTool ht : homeTools) {
//                        String c_title = ht.getC_title();
//                        List<HomeTool.HomeToolItem> goods_list = ht.getGoods_list();
//                        for (HomeTool.HomeToolItem hti : goods_list) {
//                            hti.setName(c_title);
//                            machineImageUrls.add(hti);
//                        }
//                    }
//                    MyApplication.getmInstance().setMachineImageUrls(machineImageUrls);
//                    machineGridAdapter.setData(machineImageUrls);
                    break;
                case 1000:
                    MyApplication.getmInstance().setSpecialImageUrls(specialImageUrls);
                    specialGridAdapter.setData(specialImageUrls);
                    specialGridFooter.setVisibility(View.GONE);
                    break;
                case 1001:
                    ((TextView)specialGridFooter.findViewById(R.id.tv_listview_footer)).setText(R.string.message_nomore);
                    specialGridFooter.findViewById(R.id.pbar_listview_footer).setVisibility(View.GONE);
                    nomore = true;
                    break;
            }

        }
    };
    private LinearLayout indicator;
    private ViewPager viewPager;
    private List<HomePageImage> data;
    private ArrayList<String> imageUrls;
    private ArrayList<ReduceGoods> specialImageUrls;
    private ArrayList<HomeTool.HomeToolItem> machineImageUrls;
    private SwitchPictureAdapter pagerAdapter;
    private List<ImageView> textViewList;
    private View view_parent;
    private List<HomeTool> homeTools;
//    private MachineGridAdapter machineGridAdapter;
    private SpecialListAdapter specialGridAdapter;
//    private AccessoriesGridAdapter accessoriesGridAdapter;
    private int pageno = 1;
    private boolean nomore = false;
    private View specialGridFooter;

    public HomePageFragment1029() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View ret = inflater.inflate(R.layout.fragment_home_page_1029, container, false);

        initView(inflater, ret);
        return ret;
    }

    private void initView(LayoutInflater inflater, View ret) {
//        data = new ArrayList<>();
        view_parent = ret.findViewById(R.id.view_parent);
        view_parent.setOnClickListener(this);
        viewPager = (ViewPager) ret.findViewById(R.id.auto_pager);
//        pagerAdapter = new SwitchPictureAdapter(getActivity(), viewPager, data, view_parent );
//        viewPager.setAdapter(pagerAdapter);
//        viewPager.setOnClickListener(this);
        indicator = (LinearLayout) ret.findViewById(R.id.auto_indicator);

        ret.findViewById(R.id.search_edit).setOnClickListener(this);
        ret.findViewById(R.id.new_home_protect).setOnClickListener(this);
        ret.findViewById(R.id.new_home_accessory).setOnClickListener(this);
        ret.findViewById(R.id.new_home_machine).setOnClickListener(this);
        ret.findViewById(R.id.new_home_finance).setOnClickListener(this);
        ret.findViewById(R.id.new_home_rule).setOnClickListener(this);
        ret.findViewById(R.id.new_home_forum).setOnClickListener(this);
        ret.findViewById(R.id.new_home_reduce).setOnClickListener(this);
        ret.findViewById(R.id.search_btn).setOnClickListener(this);
        ret.findViewById(R.id.home_page_to_reduce).setOnClickListener(this);
        ret.findViewById(R.id.home_page_to_tool).setOnClickListener(this);
        ret.findViewById(R.id.home_page_to_accessory).setOnClickListener(this);

        imageUrls = new ArrayList<>();
//        imageUrls.add("http://t04.pic.sogou.com/00c808820a2b47b9-7a1827e21c6bfa93-31e7255a2eff44fbac9eab97e2452f6c.jpg");
//        imageUrls.add("http://t01.pic.sogou.com/00c808820a2b47b9-b569de948d5741dd-28b2d6aa2e102ca0ba22ca3029710c27.jpg");
//        imageUrls.add("http://t04.pic.sogou.com/00c808820a2b47b9-7a1827e21c6bfa93-31e7255a2eff44fbac9eab97e2452f6c.jpg");
//        imageUrls.add("http://t02.pic.sogou.com/00c808820a2b47b9-0e20aae5349628bb-a027e58cf078a5010c2149a9b07edb04.jpg");
//        imageUrls.add("http://t03.pic.sogou.com/00c808820a2b47b9-9d86f2a6dca9d84b-366c19967c6c710ee105ea186ca56217.jpg");
//        imageUrls.add("http://t04.pic.sogou.com/00c808820a2b47b9-7a1827e21c6bfa93-31e7255a2eff44fbac9eab97e2452f6c.jpg");
//        imageUrls.add("http://t01.pic.sogou.com/00c808820a2b47b9-b569de948d5741dd-28b2d6aa2e102ca0ba22ca3029710c27.jpg");
//        imageUrls.add("http://t04.pic.sogou.com/00c808820a2b47b9-7a1827e21c6bfa93-31e7255a2eff44fbac9eab97e2452f6c.jpg");
//        imageUrls.add("http://t02.pic.sogou.com/00c808820a2b47b9-0e20aae5349628bb-a027e58cf078a5010c2149a9b07edb04.jpg");
//        imageUrls.add("http://t03.pic.sogou.com/00c808820a2b47b9-9d86f2a6dca9d84b-366c19967c6c710ee105ea186ca56217.jpg");
//        imageUrls.add("http://t04.pic.sogou.com/00c808820a2b47b9-7a1827e21c6bfa93-31e7255a2eff44fbac9eab97e2452f6c.jpg");
//        imageUrls.add("http://t01.pic.sogou.com/00c808820a2b47b9-b569de948d5741dd-28b2d6aa2e102ca0ba22ca3029710c27.jpg");
//        imageUrls.add("http://t04.pic.sogou.com/00c808820a2b47b9-7a1827e21c6bfa93-31e7255a2eff44fbac9eab97e2452f6c.jpg");
//        imageUrls.add("http://t02.pic.sogou.com/00c808820a2b47b9-0e20aae5349628bb-a027e58cf078a5010c2149a9b07edb04.jpg");
//        imageUrls.add("http://t03.pic.sogou.com/00c808820a2b47b9-9d86f2a6dca9d84b-366c19967c6c710ee105ea186ca56217.jpg");

        specialImageUrls = new ArrayList<>();
        machineImageUrls = new ArrayList<>();

        NoScrollListView specialGrid = (NoScrollListView) ret.findViewById(R.id.special_grid);
        specialGridAdapter = new SpecialListAdapter(getActivity(), specialImageUrls);
        specialGrid.setAdapter(specialGridAdapter);
        specialGrid.setOnItemClickListener(this);

        specialGridFooter = inflater.inflate(R.layout.layout_listview_footer_loading, null);
        specialGrid.addFooterView(specialGridFooter);
        specialGridFooter.setVisibility(View.GONE);

//        NoScrollGridVIew accessoriesGrid = (NoScrollGridVIew) ret.findViewById(R.id.accessories_grid);
//        accessoriesGridAdapter = new AccessoriesGridAdapter(getActivity(), imageUrls);
//        accessoriesGrid.setAdapter(accessoriesGridAdapter);

//        NoScrollGridVIew machineGrid = (NoScrollGridVIew) ret.findViewById(R.id.machine_grid);
//        machineGridAdapter = new MachineGridAdapter(getActivity(), machineImageUrls);
//        machineGrid.setAdapter(machineGridAdapter);
//        machineGrid.setOnItemClickListener(this);


//        data = MyApplication.getmInstance().getHomePageImages();

        if (data != null && data.size() > 1) {
            System.out.println("-------->" + data.size());
            pagerAdapter = new SwitchPictureAdapter(getActivity(), viewPager, data, view_parent ,this);
            viewPager.setAdapter(pagerAdapter);
//            pagerAdapter.notifyDataSetChanged();
            if (data.size() > 1) {
                viewPager.setCurrentItem(1);
            }

//            machineImageUrls = MyApplication.getmInstance().getMachineImageUrls();
//            if (machineImageUrls != null && machineImageUrls.size() > 0) {
//                machineGridAdapter.setData(machineImageUrls);
//            }
        } else {
            getData();
        }

//        specialImageUrls = MyApplication.getmInstance().getSpecialImageUrls();
        if (specialImageUrls != null && specialImageUrls.size() > 0) {
            specialGridAdapter.setData(specialImageUrls);
        } else {
            specialImageUrls = new ArrayList<>();
            getSpecialGoods(pageno);
        }

        final ScrollView scrollView = (ScrollView) ret.findViewById(R.id.home_page_scrollview);
        scrollView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                View childView = scrollView.getChildAt(0);
                switch (event.getAction()){
                    case MotionEvent.ACTION_DOWN:
                        break;
                    case MotionEvent.ACTION_MOVE:

                        break;
                    case MotionEvent.ACTION_UP:
                        if (childView  != null && childView .getMeasuredHeight() <= scrollView.getScrollY() + scrollView.getHeight()) {
                            scrollView.scrollTo(0, scrollView.getScrollY() + scrollView.getHeight());
                            getSpecialGoods(++pageno);
                        }
                        break;
                }
                return false;
            }
        });
    }

    /**
     * 首页特价
     */
    private void getSpecialGoods(int page) {
        if(nomore) return;
        specialGridFooter.setVisibility(View.VISIBLE);
        StringRequest sr = new StringRequest(Request.Method.GET, Constant.URL_REDUCE+"&page="+page,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String s) {
                        System.out.println("----special--->" + s);
                        try {
                            JSONObject jsonObject = new JSONObject(s);
                            if (jsonObject.has("datas")) {
                                JSONArray datas = jsonObject.getJSONArray("datas");
                                for (int i = 0; i < datas.length(); i++) {
                                    JSONObject jsonObject1 = datas.getJSONObject(i);
                                    JSONObject recommend = jsonObject1.getJSONObject("recommend");
                                    String name = recommend.getString("name");
//                                    if ("促销折扣".equals(name)) {
                                        JSONObject goods_list = jsonObject1.getJSONObject("goods_list");
                                        Iterator<String> keys = goods_list.keys();
                                        while (keys.hasNext()) {
                                            JSONObject jsonObject2 = goods_list.getJSONObject(keys.next());
                                            Gson gson = new Gson();
                                            ReduceGoods rg = gson.fromJson(jsonObject2.toString(), ReduceGoods.class);
                                            specialImageUrls.add(rg);
                                        }

//                                    }
                                }
                                if(datas.length()>0){
                                    mHandler.obtainMessage(1000).sendToTarget();
                                }else{
                                    mHandler.obtainMessage(1001).sendToTarget();
                                }
                            }
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {

            }
        });
        MyApplication.getmInstance().addToRequestQueue(sr);
    }

    @Override
    public void onResume() {
        super.onResume();



        mHandler.sendEmptyMessage(MSG_SWITCH_PIC);

    }

    @Override
    public void onPause() {
        super.onPause();
        mHandler.removeMessages(MSG_SWITCH_PIC);
    }


//    private void show(List<HomePageImage> list) {
//        viewPager.setOffscreenPageLimit(2);
//        pagerAdapter = new CommonImagePagerAdapter(getActivity(), list, false);
//        viewPager.setAdapter(pagerAdapter);
//        viewPager.setInterval(5000);
//        viewPager.setScrollDurationFactor(3);
//        if (list.size() > 1)
//            viewPager.startAutoScroll();
//
////        bannserSize = list.size();
////        bannerIsScrolling = true;
//        textViewList = initIndicator(list);
//        if(textViewList.size() > 0) {
//            viewPager.setCurrentItem(Integer.MAX_VALUE / 2 - (Integer.MAX_VALUE / 2) % textViewList.size());
//        }
//        viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
//
//            int index = 0;
//
//            @Override
//            public void onPageSelected(int arg0) {
//                index = arg0 % textViewList.size();
//                for (int i = 0; i < textViewList.size(); i++) {
//                    textViewList.get(i).setBackgroundResource(R.drawable.judge_01);
//                }
//                textViewList.get(index).setBackgroundResource(R.drawable.judge_02);
//            }
//
//            @Override
//            public void onPageScrolled(int arg0, float arg1, int arg2) {
//            }
//
//            @Override
//            public void onPageScrollStateChanged(int arg0) {
//            }
//        });
//    }
//
//    private List<ImageView> initIndicator(List<HomePageImage> list) {
//        List<ImageView> textViewList = new ArrayList<ImageView>();
//        ImageView textView;
//        for (int i = 0; i < list.size(); i++) {
//            textView = new ImageView(getActivity());
//            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(MyTool.dip2px(7), MyTool.dip2px(7));
//            params.setMargins(MyTool.dip2px(10),0,0,0);
//            textView.setLayoutParams(params);
//
//            if (0 == i) {
//                textView.setBackgroundResource(R.drawable.judge_02);
//            } else {
//                textView.setBackgroundResource(R.drawable.judge_01);
//            }
//            indicator.addView(textView);
//            textViewList.add(textView);
//        }
//        return textViewList;
//    }
//
//    @SuppressWarnings("deprecation")
//    protected int getScaleValue(int originalValue) {
//        int value = 0;
//        BigDecimal sacle = new BigDecimal(originalValue);
//        BigDecimal sacleChange = null;
//        switch (getActivity().getWindowManager().getDefaultDisplay().getWidth()) {
//            case 320:
//                sacleChange = new BigDecimal(Constant.MDPI_SCALE_CHANGE);
//                break;
//            case 480:
//                sacleChange = new BigDecimal(Constant.HDPI_SCALE_CHANGE);
//                break;
//            case 640:
//                sacleChange = new BigDecimal(Constant.HDPI_SCALE_CHANGE);
//                break;
//            case 720:
//                sacleChange = new BigDecimal(Constant.XHDPI_SCALE_CHANGE);
//                break;
//            case 1080:
//                sacleChange = new BigDecimal(Constant.XXHDPI_SCALE_CHANGE);
//                break;
//            default:
//                sacleChange = new BigDecimal(getActivity().getWindowManager()
//                        .getDefaultDisplay().getWidth() / 320);
//        }
//        sacle = sacle.multiply(sacleChange).setScale(0, BigDecimal.ROUND_DOWN);
//        value = sacle.intValue();
//        return value;
//    }

    private void getData() {
        DialogUtils.showLoadingDialog(getActivity(),"正在拼命加载中...",false);
        JsonObjectRequest jor = new JsonObjectRequest(Request.Method.GET, Constant.URL_SPLASH, null,
                new Response.Listener<JSONObject>() {
                    @Override
                    public void onResponse(JSONObject jsonObject) {
                        try {
                            System.out.println("---main data--->" + jsonObject.toString());
                            String code = jsonObject.getString("code");
                            if ("200".equals(code)) {
                                JSONObject datas = jsonObject.getJSONObject("datas");

//                                if (datas.has("home_list")) {
//                                    JSONArray home_list = datas.getJSONArray("home_list");
//                                    for (int i = 0; i < home_list.length(); i++) {
//                                        JSONObject jsonObject1 = home_list.getJSONObject(i);
//                                        String h_title = jsonObject1.getString("h_title");
//                                        if ("机床商城".equals(h_title)) {
//                                            JSONArray c_list = jsonObject1.getJSONArray("c_list");
//                                            Gson gson = new Gson();
//                                            homeTools = gson.fromJson(c_list.toString(), new TypeToken<List<HomeTool>>() {
//                                            }.getType());
//                                            mHandler.obtainMessage(999).sendToTarget();
//                                        }
//                                    }
//                                }

                                JSONArray adv_list = datas.getJSONArray("adv_list");
                                Gson gson = new Gson();
                                data = gson.fromJson(adv_list.toString(), new TypeToken<List<HomePageImage>>() {
                                }.getType());
                                MyApplication.getmInstance().setHomePageImages(data);
                                mHandler.obtainMessage(Constant.REQUEST_SUCCESS).sendToTarget();
                            } else {
                                mHandler.obtainMessage(Constant.REQUEST_FAIL).sendToTarget();
                            }
                        } catch (JSONException e) {
                            mHandler.obtainMessage(Constant.REQUEST_FAIL).sendToTarget();
                            e.printStackTrace();
                        }
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {
                mHandler.obtainMessage(Constant.REQUEST_FAIL).sendToTarget();
            }
        });
        jor.setRetryPolicy(new DefaultRetryPolicy(20 * 1000, 1, 1.0f));
        MyApplication.getmInstance().addToRequestQueue(jor);
    }

    @Override
    public void onClick(View v) {
        Intent intent = new Intent();
        switch (v.getId()) {
//            case R.id.home_page_store://商城
//                intent.setClass(getActivity(), StoreActivity.class);
//                break;
            case R.id.new_home_protect://维保
                intent.setClass(getActivity(), ProtectActivity.class);
                startActivity(intent);
                break;
            case R.id.new_home_rule://维保条款
                intent.setClass(getActivity(), ProtectRuleActivity.class);
                startActivity(intent);
                break;
//            case R.id.new_home_finance://金融
//                intent.setClass(getActivity(), FinanceActivity.class);
//                break;
            case R.id.new_home_forum://论坛
                intent.setClass(getActivity(), MyForumActivity.class);
                startActivity(intent);
                break;
            case R.id.search_edit:
            case R.id.search_btn://搜索页
                intent.setClass(getActivity(), SearchActivity.class);
                startActivity(intent);
                break;
//            case R.id.home_page_register://用户注册
//                intent.setClass(getActivity(), BuyProtectActivity.class);
//                break;
            case R.id.new_home_accessory://配件商城
                intent.setClass(getActivity(), AccessoryStoreActivity.class);
                startActivity(intent);
                break;
            case R.id.new_home_machine://机床商城
                intent.setClass(getActivity(), ToolStoreActivity.class);
                startActivity(intent);
                break;
//            case R.id.home_page_question://我要提问
//                intent.setClass(getActivity(), QuestionActivity.class);
//                break;
//            case R.id.home_page_niubi://技术牛人
//                intent.setClass(getActivity(),MyForumActivity.class);
//                break;
            case R.id.new_home_finance://融资租赁
                if(MyApplication.getmInstance().isLogin()) {
                    intent.setClass(getActivity(), NewFinanceActivity.class);
                    startActivity(intent);
                }else{
                    intent.setClass(getActivity(), LoginActivity.class);
                    startActivity(intent);
                }
                break;
            case R.id.new_home_reduce:
                intent.setClass(getActivity(), VipRuleActivity.class);
                startActivity(intent);
                break;
            case R.id.home_page_to_accessory:
                intent.setClass(getActivity(), AccessoryStoreActivity.class);
                startActivity(intent);
                break;
            case R.id.home_page_to_tool:
                intent.setClass(getActivity(), ToolStoreActivity.class);
                startActivity(intent);
                break;
            case R.id.home_page_to_reduce:
                intent.setClass(getActivity(), StoreActivity.class);
                startActivity(intent);
                break;
            default:
                int currentItem = viewPager.getCurrentItem();
                if(currentItem == 1){
                    startActivity(new Intent(getActivity(), VipArticleActivity.class));
                }
                if(currentItem == 4){
                    intent.setClass(getActivity(), ProtectRuleActivity.class);
                    startActivity(intent);
                }
                if(currentItem == 2){
                    Intent intent1 = new Intent(getActivity(), VipRuleActivity.class);
                    intent1.putExtra("open","");
                    startActivity(intent1);
                }
                break;
        }

    }


    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        switch (parent.getId()) {
            case R.id.special_grid:
                ReduceGoods reduceGoods = specialImageUrls.get(position);
                Intent specialIntent = new Intent(getActivity(), StoreDeatilActivity.class);
                specialIntent.putExtra("goods_id", reduceGoods.getGoods_id());
//                specialIntent.putExtra("type", Constant.TYPE_01);
                startActivity(specialIntent);
                break;
            case R.id.machine_grid:
                HomeTool.HomeToolItem homeToolItem = machineImageUrls.get(position);
                Intent machineIntent = new Intent(getActivity(), StoreDeatilActivity.class);
                machineIntent.putExtra("goods_id", homeToolItem.getGoods_id());
//                machineIntent.putExtra("type", Constant.TYPE_01);
                startActivity(machineIntent);
                break;
        }
    }
}
